package com.rpj.dao;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.rpj.entity.Book;

public interface BookDao extends JpaRepository<Book, String>,JpaSpecificationExecutor<Book>{

	@Query(value="select * from books order by bookid asc", nativeQuery=true)
	List<Book> query();
	
	
	@Modifying 
	@Transactional 
	@Query(value ="update books set bookname=?1,bookauthor=?2,bookpress=?3,booknum=?4,bookcate=?5,"
			+ "bookmessage=?6,bookprice=?7,bookaddress=?8,onlinenum=?9,borrownum=?10 where bookid=?11"+ 
			"",nativeQuery = true)
	int updateBook(String bookname,String bookauthor,String bookpress,String booknum,String bookcate,String bookmessage,String bookprice,String bookaddress,String onlinenum,String borrownum,String bookid);
	//出版社
	
	@Query(value="select bookpress from books GROUP BY bookpress",nativeQuery=true)
	List<String>  bookpress();
}
